package lu.med.praxiswahl.wahlumed.client.patienten;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.GregorianCalendar;

import javax.swing.JOptionPane;

import lu.med.praxiswahl.wahlumed.client.utilities.Parser;


/**
 * 
 * @author Lars Holger Roth
 */
public class UeberweisungDatumActionListener implements ActionListener
{
    private PatientenPanel owner;

    public UeberweisungDatumActionListener(PatientenPanel owner)
    {
	this.owner = owner;
    }

    @Override
    public void actionPerformed(ActionEvent arg0)
    {
	String input = JOptionPane
		.showInputDialog("Geben Sie das neue Datum ein:");
	if (input == null)
	    return;
	if (input.equals(""))
	    return;
	String[] inp = Parser.parseString(input, '.');
	int d, m, y;
	d = Integer.parseInt(inp[0]);
	m = Integer.parseInt(inp[1]);
	m--;
	y = Integer.parseInt(inp[2]);
	Calendar cal = new GregorianCalendar();
	cal.set(Calendar.DAY_OF_MONTH, d);
	cal.set(Calendar.MONTH, m);
	cal.set(Calendar.YEAR, y);
	owner.changeDateOfCurrentUeberweisung(cal);
    }
}
